<br /><?php
if (!defined('PATH'))
	exit();

Helper_Scripts::addScript('<link href="' . PATH . '/system/injections/store/browse/01-recently/css/screen.css" rel="stylesheet" type="text/css" media="screen" />', 'slider_css');
Helper_Scripts::addjQuery();
Helper_Scripts::addScript('<script type="text/javascript" src="' . PATH . '/system/injections/store/browse/01-recently/js/easySlider1.7.js"></script>', 'slider_js');
?>
<script type="text/javascript">
	$(document).ready(function(){
		$("#slider").easySlider({
			auto: true,
			continuous: true
		});
	});
</script>
<table border='0' cellpadding='8' cellspacing='1' width='100%'>
	<tr class='head'><td colspan='2' align='center'><b>Recently Bought</b></td></tr>
	<tr class='bold'><td colspan='2'>
			<div id="slider">
<?php
$query = $SQL->query('SELECT * FROM `__archez_store_record` JOIN `__archez_store_items` ON (`__archez_store_items`.`id` = `__archez_store_record`.`offer_id`) ORDER BY `__archez_store_record`.`time` DESC LIMIT 5');
echo '<ul>';
if (empty($query)) {
	echo '<li>Empty.</li>';
}
foreach ($query as $result) {
	if ($result['price'] == 1) {
		$point = 'point';
	} else {
		$point = 'points';
	}
	$img = null;
	if ($result['type'] == 0)
		$img = '<img src="' . PATH . '/media/images/store_items/' . $result['itemid'] . '.gif"/>';
	echo '<li>' . $img .' '. ucfirst($result['name']) . ' ' . $result['price'] . ' ' . $point . '<a href="' . PATH . '/store/buy/' . $result['id'] . '"><img  src="' . PATH . '/media/images/buy.gif"></a></li>';
}
echo '</ul>';
?>
			</div>
		</td>
	</tr>
</table>
